import Vue from "vue";
import notificAtion from "@/components/notificAtion";

let notification = {
    dom: null,
    vnode: Vue.extend(notificAtion),
    func(content, type) {
        if(this.dom) {
            console.log('v-notific');
            this.dom.$props.domHide = false
        }

        let newNotific = new this.vnode({
            propsData: {
                content: content,
                windowType: type
            }
        })
        newNotific.id = Symbol()
        this.dom = newNotific
        newNotific.vm = newNotific.$mount()
        document.body.appendChild(newNotific.vm.$el)
        // console.log('插件');
        // console.log(newNotific);
    },
    install() {
        const that = this
        Vue.component(notificAtion.name, notificAtion)
        Vue.prototype.$NotificAtion = (content, type) => {
            if(this.dom) {
                console.log('v-notific');
                this.dom.$props.domHide = false
            }
    
            let newNotific = new this.vnode({
                propsData: {
                    content: content,
                    windowType: type
                }
            })
            newNotific.id = Symbol()
            this.dom = newNotific
            newNotific.vm = newNotific.$mount()
            document.body.appendChild(newNotific.vm.$el)
            // console.log('插件');
            // console.log(newNotific);
        }
    },
}

Vue.use(notification)

const NotificAtion = notification.func
export {
    NotificAtion
}